//
//  UIHelper.swift
//  kz
//
//  Created by Tech_001 on 1/8/2017.
//  Copyright © 2017 Tech_001. All rights reserved.
//

import Foundation
import UIKit
import Lottie

@objc protocol MaintainDelegate {
    @objc func refreshMaintain()
    @objc func switchToTabSupport()
}

extension UIImage{
    
    func resizeImageWith(newSize: CGSize) -> UIImage {
        
        let horizontalRatio = newSize.width / size.width
        let verticalRatio = newSize.height / size.height
        
        let ratio = max(horizontalRatio, verticalRatio)
        let newSize = CGSize(width: size.width * ratio, height: size.height * ratio)
        UIGraphicsBeginImageContextWithOptions(newSize, true, 0)
        draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: newSize))
        let newImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return newImage!
    }
    
    static func imageWithColor(color: UIColor, size: CGSize) -> UIImage {
        let rect: CGRect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
        UIGraphicsBeginImageContextWithOptions(size, false, 0)
        color.setFill()
        UIRectFill(rect)
        let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()
        return image
    }
    
    func reSizeImage(reSize:CGSize)->UIImage {
        //UIGraphicsBeginImageContext(reSize);
        UIGraphicsBeginImageContextWithOptions(reSize,false,UIScreen.main.scale);
        self.draw(in:  CGRect(x: 0, y: 0, width: reSize.width, height: reSize.height))
        let reSizeImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext();
        return reSizeImage;
    }
}

extension URL {
    public var parametersFromQueryString : [String: String]? {
        guard let components = URLComponents(url: self, resolvingAgainstBaseURL: true),
            let queryItems = components.queryItems else { return nil }
        return queryItems.reduce(into: [String: String]()) { (result, item) in
            result[item.name] = item.value
        }
    }
}

extension String {
    //Range转换为NSRange
    func nsRange(from range: Range<String.Index>) -> NSRange {
        let from = range.lowerBound.samePosition(in: utf16)
        let to = range.upperBound.samePosition(in: utf16)
        return NSRange(location: utf16.distance(from: utf16.startIndex, to: from!),
                       length: utf16.distance(from: from!, to: to!))
    }
    
    //Range转换为NSRange
    func range(from nsRange: NSRange) -> Range<String.Index>? {
        guard
            let from16 = utf16.index(utf16.startIndex, offsetBy: nsRange.location,
                                     limitedBy: utf16.endIndex),
            let to16 = utf16.index(from16, offsetBy: nsRange.length,
                                   limitedBy: utf16.endIndex),
            let from = String.Index(from16, within: self),
            let to = String.Index(to16, within: self)
            else { return nil }
        return from ..< to
    }
}

class ScreenSize {
    static let iPhone6 = CGSize(width: 375, height: 667)
    static let iPhone6Plus = CGSize(width: 414, height: 736)
    static let iPhoneX = CGSize(width: 375, height: 812)
}

class UIHelper{
    static var _loadViews: [UIView] = []
    
    static var _effecViews: [UIView]=[]
    static var fullSize : CGRect {
        return UIScreen.main.bounds
    }
    static func round(_ control :UIView, with corners: UIRectCorner){
        self.round(control, with: corners, size: CGSize(width: 5, height: 5))
    }
    
    static func round(_ control :UIView, with corners: UIRectCorner, size: CGSize){
        let maskLayer = CAShapeLayer()
        maskLayer.path = UIBezierPath(roundedRect: control.bounds, byRoundingCorners: [corners], cornerRadii: CGSize(width: size.width, height: size.height)).cgPath
        control.layer.mask = maskLayer
    }
    
    static func removeAllSubNavigation(){
        if let mainTabBarController = GlobalInfo.mainTabBarController {
            if let presentedController = mainTabBarController.presentedViewController {
                presentedController.dismiss(animated: false, completion: nil)
            }
            
            for controller in mainTabBarController.viewControllers! {
            
                if let presentedController = controller.presentedViewController {
                    presentedController.dismiss(animated: false, completion: nil)
                }
                
                if let navController = controller as? UINavigationController {
                 
                    navController.popToRootViewController(animated: true)
                }
            }
            
            for loadView in self._loadViews {
                loadView.removeFromSuperview()
            }
        
            mainTabBarController._loadViews.removeAll()

          //  mainTabBarController.selectedIndex = 0
//             GlobalInfo.mainTabBarController?.navigationController?.popToRootViewController(animated: true)
        }
    }
    
    
    //未登陆或者已过期，清除掉cookie和登陆状态,删除自动登录 移除所有导航
    static func displayLoginExpireTip(_ controller: UIViewController){
        if UserHelper.getLoginStatus() {
            
            DispatchQueue.main.async {
                UIHelper.alertSimpleMessage(about: "当前有其它设备登录此账号!", withDescription: "", withOKButton: false)
                let defaults = UserDefaults.standard
                if let isAutoLogin = defaults.value(forKey: DefaultKey.USER_IS_AUTO_LOGIN) as? Bool {
                if isAutoLogin == true {
                    UserDefaults.standard.set(true, forKey: "mt_isLog")
                    }
                }
                defaults.set(nil, forKey: DefaultKey.LOGIN_DATA)
                RequestHelper.deleteDefaultCookie()
                UserHelper.setLoginStatus(false)
                self.removeAllSubNavigation()
                 setRootLoginVC()
            }
        }
    }
    
    static func alertSimpleMessage(about title: String, withDescription message: String, withOKButton: Bool = false){
        DispatchQueue.main.async {
           if let topController = self.getTopController() {
               if topController.isKind(of: UIAlertController.classForCoder()){
                   return
               }
               self.alertSimpleMessage(about: title, withDescription: message, in: topController, withOKButton: withOKButton)
           }
        }

    }
    static func alertIsMainTain(about title:String,withDescription message:String,urlString MainTainurl:String){
         if let topController = self.getTopController() {
        let dialogMessage =  UIAlertController(title: title, message: message, preferredStyle: .alert)
        let ok=UIAlertAction(title:"联系客服",style: .default, handler: { (action) -> Void in
            let urlString = MainTainurl
            if let url = URL(string: urlString) {
                //根据iOS系统版本，分别处理
                if #available(iOS 10, *) {
                    UIApplication.shared.open(url, options: [:],
                                              completionHandler: {
                                                (success) in
                    })
                } else {
                    UIApplication.shared.openURL(url)
                }
            }
        })
        dialogMessage.addAction(ok)
            topController.present(dialogMessage, animated: true, completion: nil)
            
        }
    }
    static func alertSimpleMessagemt(about title: String, withDescription message: String, in controller: UIViewController, withOKButton: Bool = false){
        let dialogMessage = UIAlertController(title: title, message: message, preferredStyle: .alert)
        let dialoga = dialogMessage.view.subviews[0]
        let dialogb = dialoga.subviews[0]
        let dialogc = dialogb.subviews[0]
        let dialogd = dialogc.subviews[0]
        let dialoge = dialogd.subviews[0]
        var messagefinal = dialoge.subviews[1]
        (messagefinal as! UILabel).textAlignment=NSTextAlignment.left
        //        textAlignment=NSTextAlignment.left
        dialogMessage.view.tintColor = UIColor.black
        
        if withOKButton {
            // Create OK button with action handler
            let ok = UIAlertAction(title: "确定", style: .default, handler: { (action) -> Void in
                
            })
            
            //Add OK and Cancel button to dialog message
            dialogMessage.addAction(ok)
            
            
            // Present dialog message to user
            controller.present(dialogMessage, animated: true, completion: nil)
        }else{
            // Present dialog message to user
            controller.present(dialogMessage, animated: true, completion: nil)
            
            // Auto Dismiss
            let delay = DispatchTime.now() + 1
            DispatchQueue.main.asyncAfter(deadline: delay, execute: {
                dialogMessage.dismiss(animated: true, completion: nil)
            })
        }
    }
    
    
    static func alertSimpleMessage2(about title: String, withDescription message: String, in controller: UIViewController, withOKButton: Bool = false){
        let dialogMessage = UIAlertController(title: title, message: message, preferredStyle: .alert)
        dialogMessage.view.tintColor = UIColor.black
        
        if withOKButton {
            let ok = UIAlertAction(title: "确定", style: .default, handler: { (action) -> Void in
                
            })
            dialogMessage.addAction(ok)
            controller.present(dialogMessage, animated: true, completion: nil)
        }else{
            // Present dialog message to user
            controller.present(dialogMessage, animated: true, completion: nil)
            
            // Auto Dismiss
            let delay = DispatchTime.now() + 1
            DispatchQueue.main.asyncAfter(deadline: delay, execute: {
                dialogMessage.dismiss(animated: true, completion: nil)
                if controller.navigationController?.viewControllers.count ?? 0 >= 2{
                    let vc =  controller.navigationController?.viewControllers[1];
                    controller.navigationController?.popToViewController(vc!, animated: true)
                }
                
            })
        }
        
    }
    
    static func alertSimpleMessage(about title: String, withDescription message: String, in controller: UIViewController, withOKButton: Bool = false){
        let dialogMessage = UIAlertController(title: title, message: message, preferredStyle: .alert)
//        let dialoga = dialogMessage.view.subviews[0]
//        let dialogb = dialoga.subviews[0]
//        let dialogc = dialogb.subviews[0]
//        let dialogd = dialogc.subviews[0]
//        let dialoge = dialogd.subviews[0]
//        var messagefinal = dialoge.subviews[1]
//        (messagefinal as! UILabel).textAlignment=NSTextAlignment.left
//        textAlignment=NSTextAlignment.left
        dialogMessage.view.tintColor = UIColor.black
        dialogMessage.view.tag = 5000
        if withOKButton {
            // Create OK button with action handler
            let ok = UIAlertAction(title: "确定", style: .default, handler: { (action) -> Void in
                
            })
            
            //Add OK and Cancel button to dialog message
            dialogMessage.addAction(ok)
            
            
            // Present dialog message to user
            controller.present(dialogMessage, animated: true, completion: nil)
        }else{
            // Present dialog message to user
            controller.present(dialogMessage, animated: true, completion: nil)
            
            // Auto Dismiss
            let delay = DispatchTime.now() + 1
            DispatchQueue.main.asyncAfter(deadline: delay, execute: {
                dialogMessage.dismiss(animated: true, completion: nil)
            })
        }
        
    }
    
//    static func showRequireLoginTip(_ controller: UIViewController){
//        let dialogMessage = UIAlertController(title: "登录提醒", message: "此功能仅对注册用户开放", preferredStyle: .alert)
//        dialogMessage.view.tintColor = UIColor.black
//
//        // Create OK button with action handler
//        let ok = UIAlertAction(title: "知道了", style: .default, handler: { (action) -> Void in
//
//        })
//        let reg = UIAlertAction(title: "注册/登录", style: .default, handler: { (action) -> Void in
//            setRootLoginVC()
//            // GlobalInfo.mainTabBarController?.navigationController?.popToRootViewController(animated: true)
////            controller.dismiss(animated: true, completion: nil)
//        })
//        
//        //Add OK and Cancel button to dialog message
//        dialogMessage.addAction(ok)
//        dialogMessage.addAction(reg)
//
//        // Present dialog message to user
//        controller.present(dialogMessage, animated: true, completion: nil)
//    }
    
    static func addTopBorder(inView: UIView){
        let borderTop = CALayer()
        borderTop.borderColor = UIColor.init(white: CGFloat(0.85), alpha: 1).cgColor
        borderTop.frame = CGRect(x: 0, y: 0, width: inView.frame.width, height: 0.5)
        borderTop.borderWidth = 0.25
        inView.layer.addSublayer(borderTop)
        inView.layer.masksToBounds = true
    }
    static func addBottomBorder(inView: UIView, topOffset: CGFloat = 0){
        let borderBottom = CALayer()
        borderBottom.borderColor = UIColor.init(white: CGFloat(0.85), alpha: 1).cgColor
        borderBottom.frame = CGRect(x: 0, y: inView.frame.height - 0.25 + topOffset, width: UIScreen.main.bounds.width, height: 0.5)
        borderBottom.borderWidth = 0.25
        inView.layer.addSublayer(borderBottom)
        inView.layer.masksToBounds = true
    }
    static func addTopBottomBorder(inView: UIView){
        UIHelper.addTopBorder(inView: inView)
        UIHelper.addBottomBorder(inView: inView)
    }
    
    static func getTopController(root: UIViewController?) -> UIViewController? {
        if var topController = root {
            while let presentedViewController = topController.presentedViewController {
                topController = presentedViewController
            }
            
            return topController
        }
        return nil
    }
    
    static func getTopController() -> UIViewController? {
        return self.getTopController(root: UIApplication.shared.keyWindow?.rootViewController)
    }

//    static func initLoadView(_ controller : UIViewController, withMessage: String? = "", offsetY: CGFloat = 0) -> UIView{
//        let loadView = UIView()
//        var title: String = "读取中..."
//
//        if withMessage != nil {
//            if withMessage!.characters.count > 0 {
//                title = withMessage!
//            }
//        }
//
//        let frameController = controller.parent ?? controller
//        loadView.frame = frameController.view.frame
//        loadView.backgroundColor = UIColor(white: 0.0, alpha: 0.0)
//
//        let containerView = UIView()
//        let viewFrame = CGRect(x: loadView.frame.origin.x, y: loadView.frame.origin.y, width: 130, height: 80)
//        containerView.frame = viewFrame
//        containerView.center = CGPoint(x: loadView.frame.size.width/2, y: loadView.frame.size.height/2 + offsetY)
//        containerView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin]
//        containerView.backgroundColor = UIColor(white: 0.0, alpha: 0.8)
//        containerView.clipsToBounds = true
//        containerView.layer.cornerRadius = 5
//
//        let indicatorView = UIActivityIndicatorView()
//        indicatorView.center = CGPoint(x: containerView.frame.width/2, y: containerView.frame.height/3)
//
//        let label = UILabel()
//        label.text = title
//        label.frame = containerView.bounds
//        label.center = CGPoint(x: containerView.frame.width/2, y: containerView.frame.height/2 + indicatorView.center.y/2)
//        label.textColor = UIColor.white
//        label.textAlignment = .center
//
//        containerView.addSubview(label)
//        containerView.addSubview(indicatorView)
//        loadView.addSubview(containerView)
//
//        indicatorView.startAnimating()
//
//        self._loadViews.append(loadView)
//
//        return loadView
//    }
//
    
    static func initLoadView2(withMessage: String? = "", offsetY: CGFloat = 0) -> UIView{
        let rootRect = UIApplication.shared.windows.first?.frame
        let loadView = UIView()
        var title: String = "读取中..."
        let viewFrameSize=90
        if withMessage != nil {
            if withMessage!.count > 0 {
                title = withMessage!
            }
        }
        loadView.frame =  UIScreen.main.bounds
        loadView.backgroundColor = UIColor(white: 0.0, alpha: 0.0)
        let containerView = UIView()
        let viewFrame = CGRect(x: loadView.frame.origin.x, y: loadView.frame.origin.y, width:90 ,height:90)
        containerView.frame = viewFrame
        containerView.center = CGPoint(x: loadView.frame.size.width/2, y: loadView.frame.size.height/2 + offsetY)
        containerView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin]
        //  containerView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
        containerView.backgroundColor = UIColor.clear
        containerView.clipsToBounds = true
        containerView.layer.cornerRadius = 5
//        let indicatorView = UIImageView()
//        indicatorView.animationImages = [UIImage(named:"loading_square_01")!,UIImage(named:"loading_square_02")!,UIImage(named:"loading_square_03")!,UIImage(named:"loading_square_04")!]
//
//        let indicatorViewFrame = CGRect(x: containerView.frame.width/2, y: containerView.frame.height/3,width:50,height:50)
//        indicatorView.frame = indicatorViewFrame
//        indicatorView.center = CGPoint(x: loadView.frame.size.width/2, y: loadView.frame.size.height/2-10 + offsetY)
//        //切换动作的时间3秒，来控制图像显示的速度有多快，
//        indicatorView.animationDuration = 1;
//        //动画的重复次数，想让它无限循环就赋成0
//        indicatorView.animationRepeatCount = 0;
        
        let iconAnimationView = AnimationView.init(name: "hud_load2")
         let iconAnimationViewFrame = CGRect(x: containerView.frame.width/2, y: containerView.frame.height/3,width:50,height:50)
        iconAnimationView.frame = iconAnimationViewFrame
        iconAnimationView.center = CGPoint(x: loadView.frame.size.width/2, y: loadView.frame.size.height/2-10 + offsetY)
        
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 12)
        label.text = title
        label.frame = CGRect(x: containerView.frame.width/2, y: containerView.frame.height/3,width:90,height:30)
        label.center = CGPoint(x: loadView.frame.width/2, y: loadView.frame.height/2+22+offsetY)
        label.textColor = UIColor.white
        label.textAlignment = .center
        label.isHidden = true
        
        loadView.addSubview(containerView)
        loadView.addSubview(label)
        loadView.addSubview(iconAnimationView)
        
        iconAnimationView.loopMode = .loop
           iconAnimationView.play()
         //  loadView.addSubview(indicatorView)
         //  indicatorView.startAnimating()
        self._loadViews.append(loadView)
        return loadView
    }
    static func initLoadView(_ controller : UIViewController, withMessage: String? = "", offsetY: CGFloat = 0) -> UIView{
    let rootRect = UIApplication.shared.windows.first?.frame
        let loadView = UIView()
        var title: String = "读取中..."
        let viewFrameSize=90
        if withMessage != nil {
            if withMessage!.count > 0 {
                title = withMessage!
            }
        }
        let frameController = controller.parent ?? controller
       // loadView.frame = frameController.view.frame
         loadView.frame =  UIScreen.main.bounds
        loadView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
        let containerView = UIView()
        let viewFrame = CGRect(x: loadView.frame.origin.x, y: loadView.frame.origin.y, width:90 ,height:90)
        containerView.frame = viewFrame
        containerView.center = CGPoint(x: loadView.frame.size.width/2, y: loadView.frame.size.height/2 + offsetY)
        containerView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin]
      //  containerView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
        containerView.backgroundColor = UIColor.clear
        containerView.clipsToBounds = true
        containerView.layer.cornerRadius = 5
//        let indicatorView = UIImageView()
//        indicatorView.animationImages = [UIImage(named:"loading_square_01")!,UIImage(named:"loading_square_02")!,UIImage(named:"loading_square_03")!,UIImage(named:"loading_square_04")!]
//
//        let indicatorViewFrame = CGRect(x: containerView.frame.width/2, y: containerView.frame.height/3,width:50,height:50)
//        indicatorView.frame = indicatorViewFrame
//        indicatorView.center = CGPoint(x: loadView.frame.size.width/2, y: loadView.frame.size.height/2-10 + offsetY)
//                //切换动作的时间3秒，来控制图像显示的速度有多快，
//                 indicatorView.animationDuration = 1;
//                //动画的重复次数，想让它无限循环就赋成0
//                 indicatorView.animationRepeatCount = 0;
        let iconAnimationView = AnimationView.init(name: "hud_load2")
         let iconAnimationViewFrame = CGRect(x: containerView.frame.width/2, y: containerView.frame.height/3,width:50,height:50)
        iconAnimationView.frame = iconAnimationViewFrame
        iconAnimationView.center = CGPoint(x: loadView.frame.size.width/2, y: loadView.frame.size.height/2-10 + offsetY)
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 12)
        label.text = title
        label.frame = CGRect(x: containerView.frame.width/2, y: containerView.frame.height/3,width:90,height:30)
           label.center = CGPoint(x: loadView.frame.width/2, y: loadView.frame.height/2+22+offsetY)
        label.textColor = UIColor.white
        label.textAlignment = .center
        label.isHidden = true
      
        loadView.addSubview(containerView)
        loadView.addSubview(label)
        loadView.addSubview(iconAnimationView)
        iconAnimationView.loopMode = .loop
        iconAnimationView.shouldRasterizeWhenIdle = true
        iconAnimationView.play()
      //  loadView.addSubview(indicatorView)
      //  indicatorView.startAnimating()
        self._loadViews.append(loadView)
        return loadView
    }
    

    
    static func initMaintainView(_ delegate: MaintainDelegate, showRefresh: Bool = true) -> AnnouncementAlertView {
        var maintainMessage = "正在维护"
        if let message = GlobalInfo.gameInfoData!["maintain_msg"] as? String {
            maintainMessage = message
        }
        
        let leftButton = UIButton()
        let rightButton = UIButton()
        
        var buttons: [UIButton] = []
        
        if showRefresh {
            buttons = [leftButton, rightButton]
        }else{
            buttons = [rightButton]
        }
        
        let alert = AnnouncementAlertView(title: "万博公告", content: maintainMessage, buttons: buttons, backgroundDismiss: false)
        
        leftButton.setTitle("刷新", for: .normal)
        leftButton.setBackgroundImage(UIImage(named: "btn_bg_left"), for: .normal)
        leftButton.setTitleColor(UIColor.init(red: 0.85, green: 0.82, blue: 0.79, alpha: 1), for: .normal)
        leftButton.addTarget(delegate, action: #selector(delegate.refreshMaintain), for: .touchUpInside)
        
        rightButton.setTitle("联络客服", for: .normal)
        rightButton.setBackgroundImage(UIImage(named: "btn_bg_right"), for: .normal)
        rightButton.setTitleColor(UIColor.init(red: 0.85, green: 0.82, blue: 0.79, alpha: 1), for: .normal)
        rightButton.addTarget(delegate, action: #selector(delegate.switchToTabSupport), for: .touchUpInside)
        
        return alert
    }

    static func heightForView(text:String, font:UIFont, width:CGFloat) -> CGFloat{
        let label:UILabel = UILabel(frame: CGRect(x: 0, y: 0, width: width, height: CGFloat.greatestFiniteMagnitude))
        label.numberOfLines = 0
        label.lineBreakMode = NSLineBreakMode.byWordWrapping
        label.font = font
        label.text = text
        label.sizeToFit()
        
        return label.frame.height
    }
    // 创建毛玻璃效果
    static  func  showBlurEffect(isClick click:Bool)-> UIView{
        let rootRect = UIApplication.shared.windows.first?.frame
        //首先创建一个模糊效果.light .dark .extraLight
        let blurEffect = UIBlurEffect(style: .dark)
        //接着创建一个承载模糊效果的视图
        let blurView = UIVisualEffectView(effect: blurEffect)
        blurView.alpha=0.8
        //设置模糊视图的大小（全屏）
        blurView.frame.size = CGSize(width: (rootRect?.size.width)!, height: (rootRect?.size.height)!)
        //点击自身消失
//        if(click){
//            let tap = UITapGestureRecognizer(target: self, action: #selector(removeEffect))
//            blurView.superview?.superview?.addGestureRecognizer(tap)
//        }
        //创建并添加vibrancy视图
        let vibrancyView = UIVisualEffectView(effect:
            UIVibrancyEffect(blurEffect: blurEffect))
        vibrancyView.frame.size = CGSize(width: (rootRect?.size.width)!, height: (rootRect?.size.height)!)
        blurView.contentView.addSubview(vibrancyView)
        //将文本标签添加到vibrancy视图中
        //        let label=UILabel(frame:CGRect(x:10,y:20, width:300,height:100))
        //        label.text = "hangge.com"
        //        label.font = UIFont(name: "HelveticaNeue-Bold", size: 40)
        //        label.textAlignment = .center
        //        label.textColor = UIColor.white
        //        vibrancyView.contentView.addSubview(label)
        self._effecViews.append(blurView)
     return blurView
    }
    
   static func removeEffect(){
        for effecView in UIHelper._effecViews {
              DispatchQueue.main.async {
                  effecView.removeFromSuperview()
            }
          
        }
    }
    
//    static func removeEffect(){
//        if(self._effecView.)
//    }
//    //移除毛玻璃效果
//    @objc
//    func effectViewTouch(){
//        if(self.sblurView.superview != nil){
//            self.sblurView.removeFromSuperview()
//        }
//    }
    
    
}
